#ifndef FREEWAYMGR_H_INCLUDED
#define FREEWAYMGR_H_INCLUDED

#include "../public/public0.h"
#include <string>
#include <map>
#include <set>
#include <sys/socket.h>
#include <netinet/in.h>
#include <queue>
class FreeWaySender;
class FreeWayReceiver;
class FreeWayEntry;



typedef struct sockaddr_in client;

class FreeWayMgr{
public:
    FreeWayMgr();
    ~FreeWayMgr();

    bool init(void *,int);




     bool start();
    //no use now
    void addClient(std::string sip){
        if(iplist.find(sip) == iplist.end())
        {
            iplist.insert(sip);
            LOG(INFO) << "find client, whose ip is " << sip;
        }

    }

    //current version
    void addClient(std::string name , client c)
    {
        clientlist[name] = c;
        LOG(INFO) << "find client, whose name is " <<  name;
    }

     std::map<std::string,client> & getClients()
     {
         return clientlist;
     }



    //send data
    bool send2Client(const char * , int len , std::string client = "");


    static std::string m_freewayId;
    static std::string m_freewayResp;
    static std::string m_freeWayAccess;
    static std::string m_freeWayServerIP;
private:

    FreeWayEntry * entry;

    FreeWayReceiver * fwReceiverPtr;
    FreeWaySender   * fwSenderPtr;

    void * brainp;

    std::set<std::string> iplist;
    std::map<std::string,client> clientlist;



};

#endif // FREEWAYMGR_H_INCLUDED
